package ru.ifmo.automaton.generators.fixed;

import ru.ifmo.automaton.SynchronizingAutomaton;
import ru.ifmo.automaton.SynchronizingAutomatonImpl;
import ru.ifmo.common.Source;

import java.util.HashSet;
import java.util.List;
import java.util.Map;

/**
 * Not thread safe!
 *
 * @author avhaliullin
 */
public abstract class AbstractFixedAutomatonSource<C, S> implements Source<SynchronizingAutomaton<C, S>> {
    protected abstract void rebuildIfNeed();

    public SynchronizingAutomaton<C, S> create() {
        rebuildIfNeed();
        return new SynchronizingAutomatonImpl<C, S>(
                getTransitions(),
                new HashSet<S>(),
                getInitial(),
                null,
                getAlphabet(),
                getMswLength());
    }

    protected abstract int getMswLength();

    protected abstract List<C> getAlphabet();

    protected abstract S getInitial();

    protected abstract Map<S, Map<C, S>> getTransitions();
}
